package it.uniroma2.controller;

import it.uniroma2.cloud.PROVIDER;

import com.yammer.metrics.Gauge;
import com.yammer.metrics.MetricRegistry;

public class ReporterMonitor {
	
	private ReporterChecker reporterChecker;
	
	public ReporterMonitor() {
		reporterChecker = ReporterChecker.getInstance();
		initialize();
	}

	private void initialize() {
		ControllerContextListener.mRegistry.register(
				MetricRegistry.name(PROVIDER.OPENSTACK.name() + "." + "latency"),
				new Gauge<Double>() {
					public Double getValue() {
						return reporterChecker.getLatencyMean(PROVIDER.OPENSTACK);
					}
				});
		ControllerContextListener.mRegistry.register(
				MetricRegistry.name(PROVIDER.AWS_EC2.name() + "." + "latency"),
				new Gauge<Double>() {
					public Double getValue() {
						return reporterChecker.getLatencyMean(PROVIDER.AWS_EC2);
					}
				});
		
		ControllerContextListener.mRegistry.register(
				MetricRegistry.name(PROVIDER.OPENSTACK.name() + "." + "movingAverageLoad"),
				new Gauge<Double>() {
					public Double getValue() {
						return reporterChecker.getMovingAverage_1MinLoad(PROVIDER.OPENSTACK);
					}
				});
		ControllerContextListener.mRegistry.register(
				MetricRegistry.name(PROVIDER.AWS_EC2.name() + "." + "movingAverageLoad"),
				new Gauge<Double>() {
					public Double getValue() {
						return reporterChecker.getMovingAverage_1MinLoad(PROVIDER.AWS_EC2);
					}
				});



	}

}
